<script src="../js/config.js"></script>
<%- include('../footer.ejs') -%>

    <script src="../js/echarts.js"></script>
    <!-- <script src="../js/layui.js"></script> -->
    <script src="../layui/layui.js"></script>

    <script>
        function getNowMonth() {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var d = date.getDate()
            month = month > 9 ? month : "0" + month;
            var nowMonth = year + "-" + month + '-' + d;
            return nowMonth;
        }
        /**获取上一个月 */
        function getPreMonth() {
            var arr = getNowMonth().split("-");
            var year = arr[0]; //获取当前日期的年份
            var month = arr[1]; //获取当前日期的月份
            var d = arr[2]; //获取当前日期天
            var year2 = year;
            var month2 = parseInt(month) - 1;
            if (month2 == 0) {
                //1月的上一月是前一年的12月
                year2 = parseInt(year2) - 1;
                month2 = 12;
            }

            if (month2 < 10) {
                //10月之前都需要补0
                month2 = "0" + month2;
            }
            var preMonth = year2 + "-" + month2 + '-' + d;
            return preMonth;
        }
        //时间控件
        layui.use('laydate', function() {
            var laydate = layui.laydate;


            laydate.render({
                elem: '#test-range',
                range: ['#startDate', '#endDate'],
                max: getNowMonth(),
                value: getPreMonth() + ' - ' + getNowMonth(),

                done: function(value, date, endDate) {
                    if (date.month < 10) {
                        //10月之前都需要补0
                        date.month = "0" + date.month;
                    }
                    if (endDate.month < 10) {
                        //10月之前都需要补0
                        endDate.month = "0" + endDate.month;
                    }
                    var num1 = date.year + '-' + date.month + '-' + date.date;
                    var num2 = endDate.year + '-' + endDate.month + '-' + endDate.date;
                    getTime(num1, num2);
                }
            });

        });
    </script>